package cn.getech.data.development.model.vo;

import cn.getech.data.development.entity.BdpServiceAlarm;
import cn.getech.data.intelligence.common.validator.group.AddGroup;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 服务告警
 * @author chenshiyang
 * @since 2021-05-17
 */
@Data
@ApiModel(value = "服务告警")
public class BdpServiceAlarmVO {

    //主键
    @ApiModelProperty(value = "id")
    private Integer id;
    //告警名称
    @NotNull(message = "告警名称不能为空")
    @ApiModelProperty(value = "告警名称")
    private String name;
    //服务组id
    @NotNull(message = "服务组id不能为空")
    @ApiModelProperty(value = "服务组id")
    private Integer serviceGroupId;
    //服务组名字
    @NotNull(message = "服务组名字不能为空")
    @ApiModelProperty(value = "服务组名字")
    private String serviceGroupName;
    //触发条件
    @NotNull(message = "触发条件不能为空")
    @ApiModelProperty(value = "触发条件")
    private Integer triggerCondition;
    //免打扰时间，开始
    private String noDisturbingStartTime;
    //免打扰时间，结束
    private String noDisturbingEntTime;
    //告警方式，1：邮件，2：T信，3：电话，4：短信
    @NotNull(message = "告警方式不能为空")
    @ApiModelProperty(value = "告警方式")
    private String alarmMode;
    //接收人类型，1：部门，2：项目，3：个人，4：本人
    @NotNull(message = "接收人类型不能为空")
    @ApiModelProperty(value = "接收人类型")
    private Integer receivedType;
    //告警状态，1：启用，0：禁用
    @NotNull(message = "告警状态不能为空")
    @ApiModelProperty(value = "告警状态")
    private Integer state;
    //最大告警次数
    private Integer maxAlarmCount;
    //最小告警间隔(min)
    private Integer minAlarmInterval;
    //告警发送次数
    private Integer sendCount;
    //最后一次发送时间
    private Date lastSendTime;
    //创建时间
    private Date createTime;
    //创建人
    private Integer createPer;
    //更新时间
    private Date updateTime;
    //更新人
    private Integer updatePer;
    //服务集合
    @NotNull(message = "服务集合不能为空")
    @ApiModelProperty(value = "服务集合")
    private List<Map<String,Object>> serviceList;
    //接收人集合
    @ApiModelProperty(value = "接收人集合")
    private List<Map<String,Object>> receiverList;

    public BdpServiceAlarm convert(){
        BdpServiceAlarm serviceAlarm = new BdpServiceAlarm();
        serviceAlarm.setId(this.getId());
        serviceAlarm.setName(this.getName());
        serviceAlarm.setServiceGroupId(this.getServiceGroupId());
        serviceAlarm.setServiceGroupName(this.getServiceGroupName());
        serviceAlarm.setAlarmMode(this.getAlarmMode());
        serviceAlarm.setTriggerCondition(this.getTriggerCondition());
        serviceAlarm.setNoDisturbingStartTime(this.getNoDisturbingStartTime()==null?null:DateUtil.parseTime(this.getNoDisturbingStartTime()));
        serviceAlarm.setNoDisturbingEntTime(this.getNoDisturbingEntTime()==null?null:DateUtil.parseTime(this.getNoDisturbingEntTime()));
        serviceAlarm.setReceivedType(this.getReceivedType());
        serviceAlarm.setState(this.getState());
        serviceAlarm.setMinAlarmInterval(this.getMinAlarmInterval());
        serviceAlarm.setMaxAlarmCount(this.getMaxAlarmCount());
        return serviceAlarm;
    }

}
